


package com.crm.manager.controller;


import com.crm.common.core.controller.BaseController;
import com.crm.common.core.domain.AjaxResult;
import com.crm.common.core.domain.R;
import com.crm.manager.domain.Activity;
import com.crm.manager.domain.dto.ActivityDto;
import com.crm.manager.domain.vo.PageVO;
import com.crm.manager.service.IActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 活动Controller
 *
 * @author ruoyi
 * @date 2025-03-01
 */
@RestController
@RequestMapping("/clues/activity")
@Slf4j
public class ActivityController
{
    @Autowired
    private IActivityService activityService;

    /**
     * 添加活动信息
     * @param activityDto
     * @return
     */
    @PostMapping
    public AjaxResult add(@RequestBody ActivityDto activityDto)
    {
        log.info("添加活动信息:{}",activityDto);
        activityService.addActivity(activityDto);
        return AjaxResult.success();
    }
    /**
     * 分页查询活动信息
     * @param dto
     * @return
     */
    @GetMapping("/list")
    public PageVO page(ActivityDto dto)
    {
        log.info("分页查询活动信息:{}",dto);
        PageVO page = activityService.page(dto);
        return page;
    }
    /**
     * 根据id查询活动信息
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public R<Activity> getById(@PathVariable Integer id)
    {
        Activity activity = activityService.getById(id);
        return R.ok(activity);
    }
    /**
     * 根据id删除活动信息
     * @param ids
     * @return
     */
    @DeleteMapping("/{ids}")
    public AjaxResult delete(@PathVariable Integer[] ids)
    {
        log.info("删除活动信息:{}",ids);
        activityService.delete(ids);
        return AjaxResult.success();
    }
    /**
     * 修改活动信息
     * @param activity
     * @return
     */
    @PutMapping
    public AjaxResult update(@RequestBody Activity activity)
    {
        log.info("修改活动信息:{}",activity);
        activityService.update(activity);
        return AjaxResult.success();
    }


    @GetMapping("/listselect/{channel}")
    public R<List<Activity>> listselect(@PathVariable Integer channel)
    {
        List<Activity> list = activityService.listselect(channel);
        return R.ok(list);
    }

}
